package com.pig4cloud.pigx.common.customize.api.config;

import com.pig4cloud.pigx.common.customize.api.annotation.OpenApi;
import com.pig4cloud.pigx.common.customize.api.interceptor.OpenApiInterceptor;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置{@link OpenApi}拦截器
 *
 * @since 2022/11/11 15:12
 */
@Configuration
@AllArgsConstructor
public class OpenApiInterceptorConfig implements WebMvcConfigurer {

	private final OpenApiInterceptor openApiInterceptor;

	/**
	 * 配置拦截器
	 *
	 * @param registry 拦截器注册器
	 * @since 2022/11/11 15:15
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(openApiInterceptor)
				.addPathPatterns("/**");
	}
}
